package com.yootk.config;

import org.springframework.ai.ollama.OllamaChatClient;
import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.ollama.api.OllamaOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OllamaConfig {
    @Value("${ollama.model:llama3.3}")
    private String model;
    @Value("${spring.ai.ollama.base-url:localhost:11434}")
    private String baseUrl;
    @Bean
    public OllamaApi ollamaApi() {
        OllamaApi ollamaApi = new OllamaApi(this.baseUrl);
        return ollamaApi;
    }
    @Bean
    public OllamaChatClient ollamaChatClient(@Autowired OllamaApi ollamaApi) {
        OllamaOptions options = new OllamaOptions();
        options.setModel(this.model); // ollama run llama3.3
        OllamaChatClient chatClient =new OllamaChatClient(ollamaApi).withDefaultOptions(options);
        return chatClient;
    }
}
